#coding=utf-8
from django.contrib.admin import widgets
from django.forms import ModelForm
from django.forms.models import inlineformset_factory
import models
__author__ = 'czq'
class RideLineForm(ModelForm):
    def __init__(self, *args, **kwargs):
        super(RideLineForm, self).__init__(*args, **kwargs)
        self.fields['startTime'].widget = widgets.AdminSplitDateTime()
        self.fields['endTime'].widget = widgets.AdminSplitDateTime()
    class Meta:
        model=models.RideLine
        fields=('theme','lineType','startTime','endTime',)
RideLineFormSet=inlineformset_factory(models.BbsTheme,models.RideLine,form=RideLineForm,extra=1,can_delete=False)

class RidePositionForm(ModelForm):
    class Meta:
        models=models.RidePosition
        fields=('longitude','latitude','address','positionType','arriveTime','departureTime','vehicle','rank',)
RidePositionFormSet=inlineformset_factory(models.BbsTheme,models.RidePosition,form=RidePositionForm,extra=3,can_delete=True)
#class BbsThemeVoteAttrForm(ModelForm):
#    def __init__(self, *args, **kwargs):
#        super(BbsThemeVoteAttrForm, self).__init__(*args, **kwargs)
#        self.fields['startTime'].widget = widgets.AdminSplitDateTime()
#        self.fields['endTime'].widget = widgets.AdminSplitDateTime()
#        #widgets.Admin
#    class Meta:
#        model=models_vote.BbsThemeVoteAttr
#        fields=('startTime','endTime',)

#BbsThemeVoteFormSet = inlineformset_factory(models.BbsTheme, models_vote.BbsThemeVote,form=BbsThemeVoteForm,extra=3)

#BbsThemeVoteAttrFormSet = inlineformset_factory(models.BbsTheme, models_vote.BbsThemeVoteAttr,form=BbsThemeVoteAttrForm,extra=1)
